package com.myjianzhu.zzt88.exercise.java.thread;

public class MultiThread {

    /**
     * Thread 与Runnable 的区别
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("Begin to summary!");
        ThreadRunnable runnable = new ThreadRunnable();
        new Thread(runnable).start();
        new Thread(runnable).start();
        new Thread(runnable).start();
        new Thread(runnable).start();
//        new Thread1().start();
//        new Thread1().start();
//        new Thread1().start();
//        new Thread1().start();
    }


    //1、继承Thread类
    static class Thread1 extends Thread {
        private int index = 0;

        @Override
        public void run() {
            for (int i = 0; i < 100; i++) {
                System.out.println("Thread 模拟耗时操作" + index++);
            }

        }
    }

    //    2、实现Runnable接口
    static class ThreadRunnable implements Runnable {
        private int index = 0;

        @Override
        public void run() {
            for (int i = 0; i < 100; i++) {
                System.out.println("Runnable 模拟耗时操作" + index++);
            }

        }
    }


//    3、线程池Executor

}
